package cn.algorithms_4ed.base.dataStructure;

import java.util.Iterator;

/**
 * #请替换掉这里的东东#
 * <p/>
 * User: erhu
 * Date: 13-6-11
 * Time: 下午4:46
 */
public class Stack<T> implements Iterable<T> {

    private Node<T> first;
    private int size;

    public void push(T item) {
        Node<T> old_first = first;
        first = new Node<T>();
        first.item = item;
        first.next = old_first;
        size++;
    }

    public T pop() {
        if (isEmpty()) {
            System.out.print("Stack is empty");
            return null;
        } else {
            T t = first.item;
            first = first.next;
            size--;
            return t;
        }
    }

    public boolean isEmpty() {
        return first == null;
    }

    public int size() {
        return size;
    }

    @Override
    public Iterator<T> iterator() {
        return null;
    }
}
